package iedcyt.acute.businessServices.endnote.RECNode;


import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public abstract class AbsNode {
	
	protected String _value = "";
	protected String _nodeName = "";
	/**
	 * Indice en el supuesto de que se esperen varios nodos iguales. Indica cual hay que coger
	 */
	protected int _index = 0;
	public String get_value() {
		return _value;
	}

	public void extractNodeInformation(Node node, int index)
	{
		_index = index;
		 if (node.getNodeType() == Node.ELEMENT_NODE) 
		    {
		  
		      Element element = (Element) node;
		      NodeList nodes = element.getElementsByTagName(_nodeName);
			  if (nodes != null && nodes.getLength() > _index)
			    {
					extractElementValue(nodes.item(_index));
				    extractElementSubNodes(nodes.item(_index));
				    extractElementAttributes(nodes.item(_index));
			    }
		    }
	}
	
	public void extractNodeInformation(Node node)
	{
		extractNodeInformation(node, 0);
	}
	
	protected abstract void extractElementValue(Node node);
	protected abstract void extractElementSubNodes(Node node);
	protected abstract void extractElementAttributes(Node node);
	
	
}
